﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using EnvironmentManagerSystem.BLL;
using EnvironmentManagerSystem.MODE;
using AjaxPro;
using System.Data.SqlClient;
using EnvironmentManagerSystem.Utility;
using System.Drawing;


namespace EnvironmentManagerSystem.SearchQuery
{
    public partial class SelectDevelopprojectS : System.Web.UI.Page
    {
        DataTable TreeInfo;
        TreeNode trNewNode;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (StfInfo.ReSession()) return; if (!IsPostBack)
            {
                BindTree();
                BindGridView();
                DropDownListBind(string.Empty);
            }
        }

        #region GridView
        //分页事件
        //protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        //{
        //    string aas = "";
        //    //GridView1.PageIndex = e.NewPageIndex;
        //    ViewState["Page" + GridView1.PageIndex.ToString()] = null;//必须先清空一下，否则会重复记录
        //    foreach (GridViewRow gvr in GridView1.Rows)
        //    {
        //        CheckBox check = gvr.FindControl("cbk") as CheckBox;
        //        if (check.Checked)
        //        {
        //            ViewState["Page" + GridView1.PageIndex.ToString()] += "," + gvr.DataItemIndex;   //所有页被check的索引
        //            aas = ViewState["Page" + GridView1.PageIndex.ToString()].ToString();
        //        }
        //    }
        //    GridView1.PageIndex = e.NewPageIndex;
        //    //BindGridView();
        //    ////BindKey(e.NewPageIndex);    //翻页后绑定新的页
        //    if (ViewState["Page" + GridView1.PageIndex.ToString()] != null)
        //    {
        //        aas = ViewState["Page" + GridView1.PageIndex.ToString()].ToString();
        //        string s = ViewState["Page" + GridView1.PageIndex.ToString()].ToString().TrimStart(',');
        //        aas = ViewState["Page" + GridView1.PageIndex.ToString()].ToString();
        //        string[] iIndex = s.Split(new char[] { ',' });
        //        foreach (string eveIndex in iIndex)
        //        {
        //            int index = Convert.ToInt32(eveIndex) % GridView1.PageSize;
        //        }
        //        for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        //        {
        //            (GridView1.Rows[i].Cells[0].FindControl("cbk") as CheckBox).Checked = true;
        //        }
        //    }
        //}
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //GridView1.PageIndex = e.NewPageIndex;
            ViewState["Page" + GridView1.PageIndex.ToString()] = null;//必须先清空一下，否则会重复记录
            foreach (GridViewRow gvr in GridView1.Rows)
            {
                CheckBox check = gvr.FindControl("cbk") as CheckBox;
                if (check.Checked)
                {
                    ViewState["Page" + GridView1.PageIndex.ToString()] += "," + gvr.DataItemIndex;   //所有页被check的索引
                }
            }
            GridView1.PageIndex = e.NewPageIndex;
            //BindGridView();
            ////BindKey(e.NewPageIndex);    //翻页后绑定新的页
            if (ViewState["Page" + GridView1.PageIndex.ToString()] != null)
            {
                string s = ViewState["Page" + GridView1.PageIndex.ToString()].ToString().TrimStart(',');
                string[] iIndex = s.Split(new char[] { ',' });
                foreach (string eveIndex in iIndex)
                {
                    int index = Convert.ToInt32(eveIndex) % GridView1.PageSize;
                    (GridView1.Rows[index].Cells[0].FindControl("cbk") as CheckBox).Checked = true;
                }
            }
        }
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                CheckBox mycheckBox = (CheckBox)e.Row.Cells[0].FindControl("cbk");
                if (mycheckBox != null)
                {
                    mycheckBox.ToolTip = GridView1.DataKeys[e.Row.DataItemIndex % GridView1.PageSize].Value.ToString();
                }
            }
        }
        //分页后事件
        protected void GridView1_PageIndexChanged(object sender, EventArgs e)
        {
            lbtnBind();
        }
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                int id = Convert.ToInt32(e.CommandArgument.ToString());
            }
        }
        private void BindGridView()
        {
            // 获取GridView排序数据列及排序方向   
            string sortExpression = this.GridView1.Attributes["SortExpression"];
            string sortDirection = this.GridView1.Attributes["SortDirection"];
            // 调用业务数据获取方法   
            DataTable dtBind = this.getDB();
            // 根据GridView排序数据列及排序方向设置显示的默认数据视图   
            if ((!string.IsNullOrEmpty(sortExpression)) && (!string.IsNullOrEmpty(sortDirection)))
            {
                dtBind.DefaultView.Sort = string.Format("{0} {1}", sortExpression, sortDirection);
            }
            // GridView绑定并显示数据   
            this.GridView1.DataSource = dtBind;
            this.GridView1.DataBind();
        }
        // DataTable 数据源     
        private DataTable getDB()
        {
            DataTable dt = NoticeService.GetSelectAll();
            return dt;
        }
        public SortDirection GridViewSortDirection
        {
            get
            {
                if (ViewState["sortDirection"] == null)
                    ViewState["sortDirection"] = SortDirection.Ascending;
                return (SortDirection)ViewState["sortDirection"];
            }
            set { ViewState["sortDirection"] = value; }
        }
        private void SortGridView(string sortExpression, string direction)
        {
            DataTable dt = getDB();
            DataView dv = new DataView(dt);
            dv.Sort = sortExpression + direction;
            GridView1.DataSource = dv; //将DataView绑定到GridView上
            GridView1.DataBind();
        }
        //处理GridView的排序事件
        protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
        {
            string sortExpression = e.SortExpression;
            if (GridViewSortDirection == SortDirection.Ascending) //设置排序方向
            {
                GridViewSortDirection = SortDirection.Descending;
                SortGridView(sortExpression, " DESC");
            }
            else
            {
                GridViewSortDirection = SortDirection.Ascending;
                SortGridView(sortExpression, " ASC");
            }
        }
        //鼠标滑动
        protected void GridView1_DataBound(object sender, EventArgs e)
        {
            OfficeHelper.HelpDv(GridView1);
        }
        #endregion

        #region DropDownListBind
        public void DropDownListBind(string Deparatment)
        {
            //行业类别一
            ddlIndustryType1.DataSource = EnvironmentManagerSystem.BLL.ConstructionUnit.Gethylb("14", "%");
            ddlIndustryType1.DataBind();
            ddlIndustryType1.Items.Insert(0, new ListItem("请选择", "请选择"));
            ddlIndustryType1.Items.Insert(1, new ListItem("全部", "全部"));
            //环评类别
            ddlhuanpingleibie.DataSource = EnvironmentManagerSystem.BLL.ConstructionUnit.Gethylb("7");
            ddlhuanpingleibie.DataBind();
            ddlhuanpingleibie.Items.Insert(0, new ListItem("请选择", "请选择"));
            ddlhuanpingleibie.Items.Insert(1, new ListItem("全部", "全部"));
            //项目组织人
            ddlZuZhiRen.DataSource = EnvironmentManagerSystem.BLL.XIANGMU.GetFuzeren(Deparatment);
            ddlZuZhiRen.DataTextField = "UserName";
            ddlZuZhiRen.DataValueField = "ID";
            ddlZuZhiRen.DataBind();
            ddlZuZhiRen.Items.Insert(0, new ListItem("请选择", "请选择"));
            ddlZuZhiRen.Items.Insert(1, new ListItem("全部", "全部"));
            //环评单位
            ddlhp.DataSource = EnvironmentManagerSystem.BLL.ConstructionUnit.GetList();
            ddlhp.DataBind();
            ddlhp.Items.Insert(0, new ListItem("请选择", "请选择"));
            ddlhp.Items.Insert(1, new ListItem("全部", "全部"));
            //项目执行部门
            ddlfenpeizhixingbumen.DataSource = EnvironmentManagerSystem.BLL.ExecutiveDepartmentService.GetExecutiveDepartmentAll();
            ddlfenpeizhixingbumen.DataTextField = "ed_Name";
            ddlfenpeizhixingbumen.DataValueField = "ed_Id";
            ddlfenpeizhixingbumen.DataBind();
            ddlfenpeizhixingbumen.Items.Insert(0, new ListItem("请选择", "请选择"));
            ddlfenpeizhixingbumen.Items.Insert(1, new ListItem("全部", "全部"));
            //地区代码1
            ddlAddressCode0.DataSource = EnvironmentManagerSystem.BLL.ConstructionUnit.Gethylb("30", "%00");
            ddlAddressCode0.DataBind();
            ddlAddressCode0.Items.Insert(0, new ListItem("请选择", "请选择"));
        }
        #endregion

        #region DropDownList_SelectedIndexChanged
        //行业类别一
        protected void ddlIndustryType1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //行业类别2
            ddlIndustryType2.DataSource = EnvironmentManagerSystem.BLL.ConstructionUnit.Gethylb("24", ddlIndustryType1.SelectedValue + "%");
            ddlIndustryType2.DataBind();
            ddlIndustryType2_SelectedIndexChanged(sender, e);
            ddlIndustryType2.Items.Insert(0, new ListItem("请选择", "请选择"));
            ddlIndustryType2.Items.Insert(1, new ListItem("全部", "全部"));

        }
        //行业类别二
        protected void ddlIndustryType2_SelectedIndexChanged(object sender, EventArgs e)
        {
            //行业类别3
            ddlIndustryType3.DataSource = EnvironmentManagerSystem.BLL.ConstructionUnit.Gethylb("25", ddlIndustryType2.SelectedValue + "%");
            ddlIndustryType3.DataBind();
            ddlIndustryType3_SelectedIndexChanged(sender, e);
            ddlIndustryType3.Items.Insert(0, new ListItem("请选择", "请选择"));
            ddlIndustryType3.Items.Insert(1, new ListItem("全部", "全部"));

        }
        //行业类别三
        protected void ddlIndustryType3_SelectedIndexChanged(object sender, EventArgs e)
        {
        }
        //地区代码1
        protected void ddlAddressCode0_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddlAddressCode2.Items.Clear();
            //地区代码2
            DataTable dt = EnvironmentManagerSystem.BLL.ConstructionUnit.Gethylb("30", ddlAddressCode0.Text.Substring(0, ddlAddressCode0.Text.Length - 2) + "%");
            ddlAddressCode2.DataSource = dt;
            ddlAddressCode2.DataBind();
            ddlAddressCode2_SelectedIndexChanged(sender, e);
            ddlAddressCode2.Items.Insert(0, new ListItem("请选择", "请选择"));
        }

        //地区代码2
        protected void ddlAddressCode2_SelectedIndexChanged(object sender, EventArgs e)
        {
        }
        #endregion

        #region 按钮(搜索按钮、重置按钮)(x)
        //搜索按钮
        protected void lbtnSelect_Click(object sender, EventArgs e)
        {
            lbtnBind();
        }
        private void lbtnBind()
        {
            if (txtXiangMuShouLiShiJianK.Text == "" && txtXiangMuShouLiShiJianJ.Text != "")
            {
                Response.Write("<script language='javascript'>alert('请填写要查询的受理起始时间！');</script>");
            }
            if (txtXiangMuShouLiShiJianK.Text != "" && txtXiangMuShouLiShiJianJ.Text == "")
            {
                Response.Write("<script language='javascript'>alert('请填写要查询的受理结束时间！');</script>");
            }
            if (txtTaChaRiQiK.Text == "" && txtTaChaRiQiJ.Text != "")
            {
                Response.Write("<script language='javascript'>alert('请填写要查询的踏查起始时间！');</script>");
            }
            if (txtTaChaRiQiK.Text != "" && txtTaChaRiQiJ.Text == "")
            {
                Response.Write("<script language='javascript'>alert('请填写要查询的踏查结束时间！');</script>");
            }
            if (txtHuiYiShiJianK.Text == "" && txtHuiYiShiJianJ.Text != "")
            {
                Response.Write("<script language='javascript'>alert('请填写要查询的会议起始时间！');</script>");
            }
            if (txtHuiYiShiJianK.Text != "" && txtHuiYiShiJianJ.Text == "")
            {
                Response.Write("<script language='javascript'>alert('请填写要查询的会议结束时间！');</script>");
            }
            if (txtreportdateK.Text == "" && txtreportdatej.Text != "")
            {
                Response.Write("<script language='javascript'>alert('请填写要查询的项目签发起始时间！');</script>");
            }
            if (txtreportdateK.Text != "" && txtreportdatej.Text == "")
            {
                Response.Write("<script language='javascript'>alert('请填写要查询的项目签发结束时间！');</script>");
            }

            if (cbshoulituihuishanchu.Checked == true)
            {
                string QueryCondition = string.Empty;
                GridView1.DataSource = NoticeService.GetSelectSsl(ref QueryCondition, txtXiangMuShouLiShiJianK.Text, txtXiangMuShouLiShiJianJ.Text, txtTaChaRiQiK.Text, txtTaChaRiQiJ.Text, txtHuiYiShiJianK.Text, txtHuiYiShiJianJ.Text, ddlIndustryType1.SelectedValue, ddlIndustryType2.SelectedValue, ddlIndustryType3.SelectedValue, ddlhuanpingleibie.SelectedValue, txtProjectName.Text, ddlhp.SelectedValue, ddlLiuCheng.SelectedItem.Text, ddlfenpeizhixingbumen.SelectedItem.Text, ddlZuZhiRen.SelectedItem.Text, ddlAddressCode0.SelectedValue, ddlAddressCode2.SelectedValue, ddlpingguyijianxiangmuzhuangtai.SelectedItem.Text, cbshoulituihuishanchu.Checked, cblvsetongdao.Checked, cbqueren.Checked, txthedinghetongjine.Text, ddlReceiveState.SelectedItem.Text, ddlxiangmushoulishijian.SelectedItem.Text, txtreportdateK.Text, txtreportdatej.Text, cbReports.Checked, cbReportb.Checked, cbNoticeState.Checked);
                GridView1.DataBind();
                HiddenField1.Value = QueryCondition;
            }
            else
            {
                string QueryCondition = string.Empty;
                GridView1.DataSource = NoticeService.GetSelectS(ref QueryCondition, txtXiangMuShouLiShiJianK.Text, txtXiangMuShouLiShiJianJ.Text, txtTaChaRiQiK.Text, txtTaChaRiQiJ.Text, txtHuiYiShiJianK.Text, txtHuiYiShiJianJ.Text, ddlIndustryType1.SelectedValue, ddlIndustryType2.SelectedValue, ddlIndustryType3.SelectedValue, ddlhuanpingleibie.SelectedValue, txtProjectName.Text, ddlhp.SelectedValue, ddlLiuCheng.SelectedItem.Text, ddlfenpeizhixingbumen.SelectedItem.Text, ddlZuZhiRen.SelectedItem.Text, ddlAddressCode0.SelectedValue, ddlAddressCode2.SelectedValue, ddlpingguyijianxiangmuzhuangtai.SelectedItem.Text, cbshoulituihuishanchu.Checked, cblvsetongdao.Checked, cbqueren.Checked, txthedinghetongjine.Text, ddlReceiveState.SelectedItem.Text, ddlxiangmushoulishijian.SelectedItem.Text, txtreportdateK.Text, txtreportdatej.Text, cbReports.Checked, cbReportb.Checked, cbNoticeState.Checked);
                GridView1.DataBind();
                HiddenField1.Value = QueryCondition;
            }

        }
        //重置按钮
        protected void lbtReset_Click(object sender, EventArgs e)
        {
            foreach (Control con in this.form1.Controls)
            {
                if (con is TextBox)
                    ((TextBox)con).Text = string.Empty;
                else if (con is CheckBox)
                    ((CheckBox)con).Checked = false;
                else if (con is DropDownList)
                    ((DropDownList)con).SelectedIndex = -1;
            }
        }
        #endregion

        #region TreeView
        protected void Button1_Click(object sender, EventArgs e)
        {
            #region MyRegion
            string IDlist = string.Empty;
            string aaa = "";
            IDlist += ViewState["newId"];
            if (ViewState["newId"] != null)
            {
                Session["aid"] = IDlist.Trim(',');
                aaa = Session["aid"].ToString();
            }
            else
            {
                Session["aid"] = null;
                aaa = "";
            }
            #endregion
            if (aaa != "")
            {
                List<Hashtable> list = new List<Hashtable>();
                foreach (TreeNode node in TreeView1.Nodes)
                {
                    BianLi(node, ref list);
                }
                if (list.Count > 0)
                    //TreeViewPanel.Export(list, HiddenField1.Value);
                    TreeViewPanel.Exports(list, HiddenField1.Value, aaa);
            }
            else
            {
                ts.Text = "请选择要导出数据的项目!";
                ts.ForeColor = Color.Red;

            }
        }
        private void BianLi(TreeNode Pnode, ref List<Hashtable> list)
        {
            foreach (TreeNode node in Pnode.ChildNodes)
            {
                if (node.Checked)
                {
                    Hashtable hs = new Hashtable();
                    hs.Add(node.Text, node.Value.Split(':')[1]);
                    list.Add(hs);
                }
                else if (node.ChildNodes.Count > 1)
                {
                    for (int i = 0; i < node.ChildNodes.Count; i++)
                    {
                        BianLi(node.ChildNodes[i], ref list);
                    }
                }
            }
        }

        private void BindTree()
        {
            TreeInfo = TreeViewPanel.GetTree();
            foreach (DataRow drRow in TreeInfo.Rows)
            {
                if (drRow["pid"].ToString().Trim() == "0")
                {
                    trNewNode = new TreeNode(drRow["text"].ToString().Trim(), drRow["id"].ToString().Trim());
                    trNewNode.SelectAction = TreeNodeSelectAction.Expand;
                    this.TreeView1.Nodes.Add(trNewNode);
                    if (drRow["HavaChildNode"].ToString().Trim() == "y")
                    {
                        DataTable childtable = TreeInfo.Clone();
                        foreach (DataRow row in TreeInfo.Rows)
                        {
                            if (row["pid"].ToString().Trim() == drRow["id"].ToString().Trim())
                            {
                                DataRow newRow = childtable.NewRow();
                                newRow.ItemArray = row.ItemArray;
                                childtable.Rows.Add(newRow);
                            }
                        }
                        Make_ChildNode(trNewNode, childtable);
                    }
                }
            }
        }

        protected void Make_ChildNode(TreeNode node, DataTable dtTable)
        {
            foreach (DataRow drRow in dtTable.Rows)
            {
                trNewNode = new TreeNode(drRow["text"].ToString().Trim(), drRow["id"].ToString().Trim());
                node.ChildNodes.Add(trNewNode);
                if (drRow["HavaChildNode"].ToString().Trim() == "y")
                {
                    trNewNode.Expanded = false;
                    trNewNode.SelectAction = TreeNodeSelectAction.Expand;
                    trNewNode.ShowCheckBox = false;
                    DataTable childtable = TreeInfo.Clone();
                    foreach (DataRow row in TreeInfo.Rows)
                    {
                        if (row["pid"].ToString().Trim() == drRow["id"].ToString().Trim())
                        {
                            DataRow newRow = childtable.NewRow();
                            newRow.ItemArray = row.ItemArray;
                            childtable.Rows.Add(newRow);
                        }
                    }
                    Make_ChildNode(trNewNode, childtable);
                }
                else
                {
                    if (drRow["value"].ToString().Trim() != string.Empty)
                    {
                        trNewNode.Value += ":" + drRow["value"].ToString().Trim();
                        trNewNode.ShowCheckBox = true;
                    }
                }
            }
            TreeView1.ExpandDepth = 1;
        }
        #endregion

        #region CheckBox_CheckedChanged
        protected void cbk_CheckedChanged(object sender, EventArgs e)
        {
            if (((CheckBox)sender).Checked)
            {
                if (ViewState["newId"] != null)
                {
                    if (!ViewState["newId"].ToString().Contains(((CheckBox)sender).ToolTip + ","))//判断是否已经存过，如果已经有了就不应该往里存了
                    {
                        ViewState["newId"] += ((CheckBox)sender).ToolTip + ",";
                        string a = ViewState["newId"].ToString();
                    }
                }
                else
                {
                    ViewState["newId"] = ((CheckBox)sender).ToolTip + ",";
                }
            }
            else
            {
                if (ViewState["newId"].ToString().Contains(((CheckBox)sender).ToolTip + ","))
                {
                    //去掉曾经选中而又取消选中了的ID，方便做法是用分号代替了，把它分解为数组时也方便了。
                    ViewState["newId"] = ViewState["newId"].ToString().Replace(((CheckBox)sender).ToolTip + ",", ",");
                }
            }
        }
        #endregion

        #region 查看地图_Click
        protected void LinkButton1_Click1(object sender, EventArgs e)
        {
            string IDlist = string.Empty;
            IDlist += ViewState["newId"];

            if (ViewState["newId"] != null)
            {
                Session["a"] = IDlist.Trim(',');
                string aaa = Session["a"].ToString();
            }
            else
                Session["a"] = null;
            //string IDlist = string.Empty;
            //for (int i = 0; i < GridView1.Rows.Count; i++)
            //{
            //    HtmlInputCheckBox chk = (HtmlInputCheckBox)GridView1.Rows[i].Cells[0].FindControl("cbx");
            //    if (chk.Checked)
            //        IDlist += chk.Value + ",";
            //}
            //if (IDlist != string.Empty)
            //{
            //    Session["a"] = IDlist.Trim(',');
            //    string aaa = Session["a"].ToString();
            //}
            //else
            //    Session["a"] = null;
            //Page.RegisterStartupScript("", "<script>show()</script>");
        }
        #endregion

        #region 全选
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            if (this.btnSelect.Text == "取消")
            {
                for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
                {
                    CheckBox check = (CheckBox)GridView1.Rows[i].FindControl("cbk");
                    if (ViewState["newId"].ToString().Contains(check.ToolTip + ","))
                    {
                        //去掉曾经选中而又取消选中了的ID，方便做法是用分号代替了，把它分解为数组时也方便了。
                        ViewState["newId"] = ViewState["newId"].ToString().Replace(check.ToolTip + ",", ",");
                    }
                    check.Checked = false;
                }
                btnSelect.Text = "全选";
            }
            else
            {
                for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
                {
                    CheckBox check = (CheckBox)GridView1.Rows[i].FindControl("cbk");
                    if (ViewState["newId"] != null)
                    {
                        if (!ViewState["newId"].ToString().Contains(check.ToolTip + ","))//判断是否已经存过，如果已经有了就不应该往里存了
                        {
                            ViewState["newId"] += check.ToolTip + ",";
                        }
                    }
                    else
                    {
                        ViewState["newId"] = check.ToolTip + ",";
                    }
                    check.Checked = true;
                }
                btnSelect.Text = "取消";
            }
        }
        #endregion

        #region MyRegion
        protected void Button2s_Click(object sender, EventArgs e)
        {
            string ID1 = "";
            if (this.Button2s.Text == "取消")
            {
                for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
                {
                    CheckBox check = (CheckBox)GridView1.Rows[i].FindControl("cbk");
                    if (ViewState["newId"].ToString().Contains(check.ToolTip + ","))
                    {
                        //去掉曾经选中而又取消选中了的ID，方便做法是用分号代替了，把它分解为数组时也方便了。
                        ViewState["newId"] = ViewState["newId"].ToString().Replace(check.ToolTip + ",", ",");
                    }
                    check.Checked = false;
                }
                ViewState["newId"] = null;
                Button2s.Text = "全选";
            }
            else
            {
                DataTable dt = NoticeService.GetSelectAll();
                if (dt.Rows.Count == 0)
                    return;
                foreach (DataRow dr in dt.Rows)
                {
                    ID1 = dr["ID"].ToString();
                    //ID2 = ID2 + ID1 + ",";
                    if (ViewState["newId"] != null)
                    {
                        if (!ViewState["newId"].ToString().Contains(ID1 + ","))//判断是否已经存过，如果已经有了就不应该往里存了
                        {
                            ViewState["newId"] += ID1 + ",";
                        }
                    }
                    else
                    {
                        ViewState["newId"] = ID1 + ",";
                    }
                }
                for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
                {
                    CheckBox check = (CheckBox)GridView1.Rows[i].FindControl("cbk");
                    check.Checked = true;
                }
                Button2s.Text = "取消";
            }
        }
        #endregion
    }
}